package com.boot.mgt.controller.web

import com.boot.core.result.ResultTo
import com.boot.mgt.service.TaDocumentsService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse


/**
 * 报警管理接口
 */
@RestController
@RequestMapping("/admin/documents")
class TaDocumentsExportController {
    @Autowired
    private lateinit var documentsExportService:TaDocumentsService

    @GetMapping("/test")
    fun test(request: HttpServletRequest, response: HttpServletResponse) {
        val begin = request.getParameter("occur_time_begin")
        val end = request.getParameter("occur_time_end")

        documentsExportService.testFun(response)
    }

    @GetMapping("/export")
    fun export(request: HttpServletRequest, response: HttpServletResponse) {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        documentsExportService.export(beginDate, endDate, response)
    }

    @GetMapping("/getTQChartsData")
    fun getTQChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getTQChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getHoursChartsData")
    fun getHoursChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getHoursChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getSGXTChartsData")
    fun getSGXTChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getSGXTChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getCLSYXZChartsData")
    fun getCLSYXZChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getSGXTChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getCauseChartsData")
    fun getCauseChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getCauseChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getDLLXChartsData")
    fun getDLLXChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getDLLXChartsData(beginDate, endDate, response)
    }

    @GetMapping("/getVehicleTypeChartsData")
    fun getVehicleTypeChartsData(request: HttpServletRequest, response: HttpServletResponse):ResultTo {
        val beginDate= request.getParameter("begin_date")
        val endDate = request.getParameter("end_date")

        return documentsExportService.getVehicleTypeChartsData(beginDate, endDate, response)
    }

}